FROM php:8.3-fpm-alpine3.18
LABEL author="slpcode"
LABEL email="1370808424@qq.com"
# 安装php扩展
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \
#RUN apk add --no-cache tzdata git \
     && apk upgrade \
#RUN apk upgrade \
    && apk add --no-cache tzdata git \
    icu-dev gettext-dev libxml2-dev libzip libzip-dev \
    libmcrypt-dev libjpeg-turbo-dev libpng-dev libwebp libwebp-dev freetype-dev autoconf g++ make \
    openssl openssl-dev \
    && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && apk del tzdata
RUN apk add --no-cache linux-headers

RUN docker-php-ext-install bcmath exif gettext intl pcntl shmop soap sockets sysvmsg sysvsem sysvshm zip pdo_mysql mysqli ftp \
    && docker-php-ext-configure gd --with-freetype=/usr/include/freetype2/ --with-jpeg=/usr/include/ --with-webp=/usr/include/webp \
    && docker-php-ext-install gd

COPY ./ext /tmp/ext

RUN pecl -vvv install /tmp/ext/mongodb-1.17.0.tgz
RUN pecl -vvv install /tmp/ext/swoole-5.1.1.tgz
RUN pecl -vvv install /tmp/ext/redis-6.0.2.tgz
RUN pecl -vvv install /tmp/ext/xdebug-3.3.0.tgz
RUN pecl -vvv install /tmp/ext/xlswriter-1.5.5.tgz
#RUN pecl -vvv install /tmp/ext/ssh2-1.4.tgz

RUN apk --update add imagemagick \
    && apk add imagemagick-dev

RUN cd /tmp/ext && \
    tar xzvf imagick-3.7.0.tgz && cd imagick-3.7.0 && \
    phpize && ./configure && \
    make && make install

RUN apk --update add libssh2 \
    && apk add libssh2-dev

RUN cd /tmp/ext && \
    tar xzvf ssh2-1.4.tgz && cd ssh2-1.4 && \
    phpize && ./configure && \
    make && make install

RUN rm -r /tmp/ext

RUN docker-php-ext-enable imagick
RUN docker-php-ext-enable mongodb
RUN docker-php-ext-enable swoole
RUN docker-php-ext-enable redis
RUN docker-php-ext-enable xlswriter
RUN docker-php-ext-enable ssh2
#RUN docker-php-ext-enable xdebug


COPY --from=composer /usr/bin/composer /usr/bin/composer

ENV PATH $PATH:/composer83/vendor/bin
ENV COMPOSER_HOME /composer83

RUN mkdir /composer83
#RUN /usr/bin/composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

RUN apk add supervisor
